package com.hieubq.demo.screenlock.theme.snail.activity;

import java.util.Calendar;

import com.hieubq.demo.screenlock.theme.snail.R;
import com.hieubq.demo.screenlock.theme.snail.receiver.ScheduleReceiver;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;


public class MainActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
//		requestWindowFeature(Window.FEATURE_NO_TITLE);
//		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
//				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
//		setContentView(R.layout.activity_screen_on_off);

		AlarmManager service = (AlarmManager) this
				.getSystemService(Context.ALARM_SERVICE);
		Intent i = new Intent(this, ScheduleReceiver.class);
		PendingIntent pending = PendingIntent.getBroadcast(this, 0, i,
				PendingIntent.FLAG_CANCEL_CURRENT);
		Calendar cal = Calendar.getInstance();
		// Start 30 seconds after boot completed
		cal.add(Calendar.SECOND, 1);
		//
		// Fetch every 30 seconds
		// InexactRepeating allows Android to optimize the energy consumption
		service.setInexactRepeating(
				AlarmManager.RTC_WAKEUP,
				cal.getTimeInMillis(),
				com.hieubq.demo.screenlock.theme.snail.receiver.StartupReceiver.REPEAT_TIME,
				pending);

		this.startService(new Intent(this, com.hieubq.demo.screenlock.theme.snail.service.MonitorService.class));
	}

}
